﻿function pageLastSetting(sqlStr,pageindex)
{
   document.getElementById('txtPageIndex').value=parseInt(pageindex,10)
   document.getElementById('txt_sql').value=sqlStr
   
}
function pageIndexSetting(pageindex)
{
      if(pageindex=='First'|| pageindex=='submit')
    {
        pageindex=1
    }
    else //末页.设置索引为最大页
    if(pageindex=='Last')
    {
    pageindex=document.getElementById('txtPageCount').value 
    }
    else//前页
    if(pageindex=='Above')
    {
      pageindex=parseInt(document.getElementById('txtPageIndex').value,10)-1
    
    }
    else//后翻页
    if(pageindex=='Next')
    {
      pageindex=parseInt(document.getElementById('txtPageIndex').value,10)+1
    }
    else//查询页
    if(pageindex=='Search')
    {
     pageindex=parseInt(document.getElementById('txtPageIndex').value,10)
    }
    if(pageindex<1)//如果小于1.前页无效
    {
    pageindex=1
    }
    else //大于等于总页数,末页无效,索引设置为最大页去1.此时pageindex!=1的条件是为了防止页加载时进入判断,因为页加载时document.getElementById('txtPageCount').value为Nan
    if(pageindex!=1 && pageindex>=document.getElementById('txtPageCount').value)
    {   
        pageindex=document.getElementById('txtPageCount').value
    } 
    return pageindex;
}
function setTable(response)
{ //debugger
   var Record=response.value;
if(Record!=null)
{
   var sysRecord=Record[0]
 
  document.getElementById('txtPageCount').value=Record[1]
  document.getElementById('txtRecordCount').value=Record[2]
  document.getElementById('loadinfo').innerHTML=sysRecord

ShowLink();
}
}
function getNumber(e) 
{
       var keynum=e.which;
    var numcheck;
    var keychar;  
    if(window.event) // IE
    {keynum = e.keyCode}
    else if(e.which) // Netscape/Firefox/Opera
    {keynum = e.which}
     keychar = String.fromCharCode(keynum)
     numcheck = /\d/
     return numcheck.test(keychar)
}
function ShowLink()
{
     //进入时启用 首页,初始 末页,下一页
       document.getElementById('tdFirst').style.color="#3366ff";
       document.getElementById('tdAbove').style.color="#3366ff";     
       document.getElementById('tdNext').style.color="#3366ff";
       document.getElementById('tdLast').style.color="#3366ff";
               
       document.getElementById('tdNext').style.cursor='pointer'; 
       document.getElementById('tdLast').style.cursor='pointer';
       document.getElementById('tdFirst').style.cursor='pointer'; 
       document.getElementById('tdAbove').style.cursor='pointer';  
       
       //获取总页数与页码
       var iPageCount =document.getElementById('txtPageCount').value;
       var iPageIndex =document.getElementById('txtPageIndex').value;
       //显示或隐藏转页链接
            if (iPageIndex == iPageCount)
            {
                document.getElementById('tdNext').style.cursor='normal'; 
                document.getElementById('tdLast').style.cursor='normal';
                document.getElementById('tdNext').style.color="lightgrey";
                document.getElementById('tdLast').style.color="lightgrey";
            }
            if (iPageIndex == 1)
            {  
             document.getElementById('tdFirst').style.color="lightgrey";
             document.getElementById('tdAbove').style.color="lightgrey";  
             document.getElementById('tdFirst').style.cursor='normal'; 
             document.getElementById('tdAbove').style.cursor='normal';    
            }
}